import type { FieldRule } from 'vant'

const MobileRule: FieldRule[] | undefined = [
  { required: true, message: '请填写手机号' },
  {
    pattern: /^(?:(?:\+|00)86)?1\d{10}$/,
    message: '请输入正确的手机号'
  }
]
const PasswordRule: FieldRule[] | undefined = [
  { required: true, message: '请填写密码' }
]
const CodeRule: FieldRule[] | undefined = [
  { required: true, message: '请填写验证码' },
  {
    pattern: /^\d{6}$/,
    message: '请输入正确的验证码'
  }
]
// 姓名的表单验证
const nameRules: FieldRule[] = [
  { required: true, message: '请输入姓名' },
  { pattern: /^(?:[\u4e00-\u9fa5·]{2,16})$/, message: '中文2-16个字符' }
]
// 身份证号的表单验证
const idCardRules: FieldRule[] = [
  { required: true, message: '请输入身份证号' },
  {
    pattern:
      /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/,
    message: '身份证号不正确'
  }
]
export { MobileRule, PasswordRule, CodeRule, nameRules, idCardRules }
